// 使用count统计换行符数目

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int count_lines(const string& file) {
    ifstream in(file);
    return count(
        istreambuf_iterator<char>(in),
        istreambuf_iterator<char>(),
        '\n'
    );
}

vector<int> count_lines_in_files(vector<string>& files) {
    vector<int> results;
    for (const auto& file : files) {
        results.push_back(count_lines(file));
    }
    return results;
}

int main() {
    vector<string> files{"ch01/1_2.cpp"};
    for (int line_count : count_lines_in_files(files)) {
        cout << line_count << "\n";
    }
}
